home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
sampler4.arc
/
FORECAST.SAC
< prev
next >
Wrap
Text File
|
1985-08-30
|
14KB
|
391 lines
!*******************************************************************!
! !
! Forecasting the Single Equation Model !
! (Section 9.4) !
! !
!*******************************************************************!
ON ECHO
! Forecasting with SORITEC SAMPLER is accomplished by RECOVERing
! the fitted equation from SORITEC's internal variables after
! estimation, changing the USE period to the forecast interval, and
! executing the FORECAST command. SAMPLER's forecasting capabilities
! are demonstrated with an example adapted from R.W. Kopcke,
! "Forecasting Investment Spending: The Performance of Statistical
! Models", New England Economic Review, November/December, 1982.
!
! In this example, we estimate two of the models evaluated in that
! study for forecasting investment in nonresidential structures:
! (1) The General Accelerator Model
! (2) The Time Series Model
! The General Accelerator Model relates gross private investment in
! nonresidential structures to gross domestic business product and
! net stocks of nonresidential structures. The Time Series Model
! relates the ratio of gross private investment and net stocks of
! residential structures lagged by one period to the ratio from the
! previous period. Independent variables in both equations are
! lagged several periods back.
!
! This example differs from the Kopcke study in both the data and
! estimator used to estimate the equations. Identical results
! should therefore not be expected.
!
! The equations are estimated from 1954q1 to 1977q4; forecasts are
! evaluated over the 1978q1 to 1980q4 period. Since independent
! variables are lagged several quarters back, data from 1951q1 are
! read into SORITEC SAMPLER. Data definitions are:
!
! qpi = gross private investment in nonresidential
! structures
! gdbp = gross domestic business product
! nonres_stocks = net stocks of nonresidential structures
!
! All data are expressed in 1972 dollars.
!
USE 1951Q1 1981Q4
READ qpi gdbp nonres_stocks
20.4 290.37 212.285
21.1 293.18 214.449
21.0 297.06 216.341
20.1 299.83 218.194
20.2 301.93 219.826
20.4 299.83 221.699
20.6 301.60 223.370
21.4 317.93 225.434
22.0 325.07 227.386
22.5 328.88 229.658
22.6 326.74 231.688
23.1 314.62 234.039
23.5 312.10 236.217
23.7 311.91 238.645
23.7 315.90 241.038
23.7 325.03 243.397
24.5 339.87 245.919
25.0 349.06 248.528
25.9 353.77 251.319
26.4 360.03 254.194
27.3 360.79 257.508
28.4 362.50 260.792
28.8 360.41 264.128
28.8 367.20 267.685
28.5 370.94 270.855
28.5 369.76 274.255
28.4 368.58 277.312
28.3 361.67 280.301
27.9 347.20 283.434
26.9 346.27 285.997
26.2 357.20 288.349
26.4 372.40 290.718
26.3 385.87 293.028
27.2 399.29 295.824
28.0 391.06 298.487
27.9 393.59 301.390
29.3 409.83 304.301
29.0 406.35 307.404
29.2 400.68 310.212
30.6 396.69 313.639
30.6 398.89 316.711
30.1 408.79 319.935
30.1 415.73 322.800
29.9 428.45 325.900
30.4 438.04 328.901
31.6 441.13 332.159
32.7 446.08 335.980
31.9 448.65 339.221
30.6 454.69 342.094
32.1 465.28 345.299
32.3 471.39 348.509
32.8 476.69 351.799
32.8 488.96 355.044
34.3 495.49 358.615
35.1 503.30 362.336
35.6 507.50 366.129
37.6 525.09 370.736
40.7 532.16 375.689
40.9 539.42 380.623
43.4 553.87 386.110
43.8 566.45 391.620
43.2 571.17 396.507
44.1 576.32 401.937
42.7 580.54 406.942
42.8 581.53 411.490
41.7 584.79 416.103
41.9 591.29 420.701
41.5 599.63 425.136
43.0 608.77 429.881
42.4 620.19 434.411
42.1 631.16 438.803
43.6 639.04 443.507
44.1 645.39 448.269
44.5 648.75 453.064
45.9 653.08 458.140
45.4 650.00 463.021
44.2 643.46 467.535
44.3 644.90 472.012
43.9 650.64 476.327
43.3 640.70 480.433
43.2 660.25 484.456
42.9 662.96 488.349
43.0 670.16 491.721
42.3 680.18 495.353
43.5 698.07 499.232
43.9 711.45 503.156
44.0 720.35 507.051
45.2 739.28 511.188
45.9 759.64 515.442
47.3 757.51 520.504
48.3 758.00 525.235
47.9 763.59 529.801
46.6 755.51 533.973
45.2 756.38 538.278
41.8 751.28 541.691
40.8 739.88 544.278
38.6 720.60 546.828
37.6 733.36 548.556
38.3 755.08 550.984
38.5 766.15 552.889
39.2 790.39 555.494
39.4 793.51 557.014
39.8 800.75 559.159
39.5 805.49 561.198
38.9 823.77 563.059
40.2 849.78 565.219
41.3 870.62 567.622
41.2 873.84 570.535
41.9 877.78 572.455
44.7 903.70 575.605
45.7 909.09 578.960
46.2 920.95 582.393
46.6 924.03 585.295
48.2 918.39 588.539
50.4 922.38 592.268
51.2 919.65 596.127
50.9 928.33 600.218
48.4 908.49 603.854
47.5 910.13 607.217
48.3 923.83 610.731
50.4 940.97 614.867
52.3 942.98 619.351
55.0 948.08 624.448
55.1 928.47 629.499
;
END
!
! As the Time Series Model requires both the dependent and independent
! variables to be expressed as ratios, transform the variables before
! estimating the model.
!
USE 1954q1 1981q4
lag_0 = qpi(0)/nonres_stocks(-1)
lag_1 = qpi(-1)/nonres_stocks(-1)
lag_2 = qpi(-2)/nonres_stocks(-1)
lag_3 = qpi(-3)/nonres_stocks(-1)
!
! Define names for the transformed variables in a GROUP statement.
!
GROUP tsm_vars lag_0 lag_1 lag_2 lag_3
ON GROUP
!
! Now estimate the Time Series Model using OLS.
!
REGRESS tsm_vars
OFF GROUP
!
! In order to forecast, we must recover the fitted equation which is
! stored as a SORITEC internal variable under the name, ^FOREQ.
! Also, we want to recover rho, which measures the autocorrelation
! between residual terms. Rho is stored as the first element of the
! internal SORITEC variable ^AUTOCOR and is used correct the
! raw forecast data as was done in the Kopcke article.
!
RECOVER tsm_fitted FOREQ
SET tsm_rho = ^AUTOCOR(1)
!
! Now estimate the General Accelerator Model over the 1954q1 to 1977q4
! period. Note that in this specification, gross domestic business
! product is lagged from t=0 to t=-5. These can be specified quite
! simply in SORITEC as shown in the command line. Again, OLS is used
! to estimate the model
!
REGRESS qpi gdbp(0 to -5) nonres_stocks(-1)
!
! Again, RECOVER the fitted equation and rho.
!
RECOVER gam_fitted FOREQ
SET gam_rho = ^AUTOCOR(1)
!
! The important thing to remember when FORECASTing a fitted equation is
! that the original dependent variable is replaced by forecast values of
! the dependent variable over the period being forecast. Because of this,
! it is advisable either to databank the original data series (remember,
! all observations will be saved regardless of the active USE period), or
! copy the original series into another via a transformation, i.e.,
!
USE 1951Q1 1981Q4
qpi_original = qpi
!
! Now adjust the USE period to the period over which forecasts are to
! be made.
!
USE 1978q1 1981q4
!
! Then simply forecast the dependent variable for each model.
!
! (1) For the Time Series Model:
!
FORECAST tsm_fitted
!
! Transform the dependent variable for the Time Series Model back into
! gross private investment in nonresidential structures.
!
qpi_tsm = lag_0 * nonres_stocks(-1)
!
! (2) For the General Accelerator Model:
!
FORECAST gam_fitted
!
! Copy the forecast dependent variable into qpi_gam (for consistencey).
!
qpi_gam = qpi
!
! Print out the original and two forecast values for gross private
! investment in nonresidential structures.
!
PRINT qpi_original qpi_tsm qpi_gam
!
! Plot the original data and the two forecast estimates.
! Let qpi_original = O
! qpi_tsm = T
! qpi_gam = G
!
PLOT qpi_original O qpi_tsm T qpi_gam G
!
! Correct the raw forecast error by subtracting the product of the
! raw forecast error from the previous quarter and the equations
! autocorrelation coefficient (rho) from the raw forecast error
! for the current quarter. (Set the 1977q4 values of qpi_tsm and
! qpi_gam to the actual values, first. Note that you must REVISE
! the series or the forecast values will be wiped out.)
!
USE 1977q4
REVISE qpi_tsm = qpi_original
REVISE qpi_gam = qpi_original
USE 1978q1 1981q4
tsm_error = (qpi_original - qpi_tsm) &
- tsm_rho * (qpi_original(-1) - qpi_tsm(-1))
gam_error = (qpi_original - qpi_gam) &
- gam_rho * (qpi_original(-1) - qpi_gam(-1))
!
! Now calculate error statistics similar to those in the Kopcke
! article:
!
! (1) mean error
!
DOT tsm_error gam_error
SUM error_sum :
SET mean_: = error_sum/16
ENDDOT
!
! (2) mean absolute error
!
DOT tsm_error gam_error
abs_: = abs(:)
SUM error_sum abs_:
SET mean_abs_: = error_sum/16
ENDDOT
!
! (3) root mean square error.
!
DOT tsm_error gam_error
squared_: = : ** 2
SUM error_sum squared_:
SET mean_squared_: = (error_sum/16)**0.5
ENDDOT
!
! Write out results in formatted form and compare to Kopcke results
!
! First enter Kopcke results, as vectors.
!
VECTOR gam_vec .57 1.0 1.1
VECTOR tsm_vec .52 1.1 1.3
!
! Set up the format statements
!
100 FORMAT(/////15x,&
'Error Statistics for Static Forecasts of Investment Models')
101 FORMAT(31x,'1978Q1 to 1981Q4')
102 FORMAT(11x,'Estimated Results',25x,'Kopcke Results')
103 FORMAT(2(17x,'Mean',7x,'Root Mean',2x),/,2(4x,'Mean',7x,'Absolute', &
6x,'Squared',3x)/6(4x,'Error',4x)/)
104 FORMAT(6(f9.2,4x))
105 FORMAT(' General Accelerator Model')
106 FORMAT(' Time Series Model')
!
! Write out the results. Since we don't want the results written
! out after each command (the commands and output would be intermixed),
! disable the ECHO option with the OFF ECHO command. This simply turns
! off the printing of input lines to the output device.
!
OFF ECHO
WRITE(100)
WRITE(101)
WRITE(102)
WRITE(103)
WRITE(105)
WRITE(104) mean_gam_error mean_abs_gam_error mean_squared_gam_error gam_vec
WRITE(106)
WRITE(104) mean_tsm_error mean_abs_tsm_error mean_squared_tsm_error tsm_vec
ON ECHO
QUIT